package com.dt.global.web.action.zhengym;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;
import org.codehaus.jackson.map.ObjectMapper;
import org.hibernate.HibernateException;
import org.springframework.context.annotation.Scope;

import com.dt.components.exstruts.action.BaseActionSupport;
import com.dt.components.exutils.PageUtil;
import com.dt.global.entitys.bo.TWebCoreArticle;
import com.dt.global.entitys.bo.TWebCoreChannel;
import com.dt.global.entitys.bo.TWebCoreMien;
import com.dt.global.entitys.bo.TWebLinks;
import com.dt.global.utils.Proerties;
import com.dt.global.web.mar.Newscentrality.NewscentralityMar;
import com.dt.global.web.mar.articleQuery.ArticleQueryMar;
import com.dt.global.web.mar.linksquery.LinksQueryMar;
import com.dt.global.web.mar.repquery.RepQueryMar;

/**
 * 镇街道首页新闻查询
 * @author MWG
 *
 */
@Scope("prototype")
public class ZjdNewcentralityAction extends BaseActionSupport {
	private static final long serialVersionUID = 1L;
	//json解析对象
	public ObjectMapper mapper=new ObjectMapper();
	@Resource
	public NewscentralityMar newMar;
	@Resource
	private RepQueryMar repQueryMar;
	@Resource
	public LinksQueryMar linksQueryMar;
	@Resource
	public ArticleQueryMar articleQueryMar;
	/**
	 * 查询首页人大要闻
	 * @return
	 */
	public String addrdNews(){
		HttpServletRequest req = 
			ServletActionContext.getRequest();
		HttpServletResponse resp = 
			ServletActionContext.getResponse();
		resp.setContentType("text/html;utf-8");
		resp.setCharacterEncoding("utf-8");
		try {
			Proerties popUtil = new Proerties();
		    String channelId=null;
		    String pid = getRequest().getParameter("pid");
		    if(pid!=null){
		    	if(pid.equals("11")){//万春镇
					channelId="channelId201311281585792969475072";
				}else if(pid.equals("13")){ //和盛镇
					channelId="channelId201311281585815806493696";
				}else if(pid.equals("15")){ //永宁镇
					channelId="channelId201311281585828414342144";
				}else if(pid.equals("12")){ //寿安镇
					channelId="channelId201311281585801691890688";
				}else if(pid.equals("16")){ //柳城街道
					channelId="channelId201311281585833448342528";
				}else if(pid.equals("22")){ //文教卫体口
					channelId="channelId201311281585862193120256";
				}else if(pid.equals("17")){ //天府街道
					channelId="channelId201311281585839130952704";
				}else if(pid.equals("18")){ //涌泉街道
					channelId="channelId201311281585844317635584";
				}else if(pid.equals("19")){ //公平街道
					channelId="channelId201311281585848800478208";
				}else if(pid.equals("20")){ //永盛镇
					channelId="channelId201311281585853085156352";
				}else if(pid.equals("21")){ //金马镇
					channelId="channelId201311281585856996508672";
				}
		    	List<Map<String,String>> list = new ArrayList<Map<String,String>>();
				List<TWebCoreArticle> listArticle = newMar.getTWebCoreArticle(channelId);
				//声明Map对象
				Map<String,String> map = null;
				if(listArticle!=null&listArticle.size()>0){
					for (TWebCoreArticle core : listArticle) {
						map = new HashMap<String, String>();
						if(core.getTitle().length()>18){
							map.put("title", core.getTitle().substring(0, 18)+"...");
						}else{
							map.put("title", core.getTitle());
						}
						map.put("time", core.getReleaseSysDate().substring(0,10));
						map.put("articleId", core.getArticleId());
						map.put("channelId", core.getChannelId());
						list.add(map);
					}
				}
				String json = mapper.writeValueAsString(list);
				PrintWriter out  =resp.getWriter();
				out.print(json);
				out.flush();
				out.close();
				return null;
		    }else{
		    	return "error";
		    }
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}
	}
	/**
	 * 查询首页通知公告
	 * @return
	 */
	public String addtzggNews(){
		HttpServletRequest req = 
			ServletActionContext.getRequest();
		HttpServletResponse resp = 
			ServletActionContext.getResponse();
		resp.setContentType("text/html;utf-8");
		resp.setCharacterEncoding("utf-8");
		try {
			Proerties popUtil = new Proerties();
		    String channelId=null;
		    String pid = getRequest().getParameter("pid");
		    if(pid!=null){
		    	if(pid.equals("11")){//万春镇
					channelId="channelId201311281585789843555328";
				}else if(pid.equals("13")){ //和盛镇
					channelId="channelId201311281585809706107904";
				}else if(pid.equals("15")){ //永宁镇
					channelId="channelId201311281585820720120832";
				}else if(pid.equals("12")){ //寿安镇
					channelId="channelId201311281585800876786688";
				}else if(pid.equals("16")){ //柳城街道
					channelId="channelId201311281585831893500928";
				}else if(pid.equals("22")){ //文教卫体口
					channelId="channelId201311281585861550539776";
				}else if(pid.equals("17")){ //天府街道
					channelId="channelId201311281585837519258624";
				}else if(pid.equals("18")){ //涌泉街道
					channelId="channelId201311281585842498192384";
				}else if(pid.equals("19")){ //公平街道
					channelId="channelId201311281585847585440768";
				}else if(pid.equals("20")){ //永盛镇
					channelId="channelId201311281585851651130368";
				}else if(pid.equals("21")){ //金马镇
					channelId="channelId201311281585855880594432";
				}
		    	List<Map<String,String>> list = new ArrayList<Map<String,String>>();
				List<TWebCoreArticle> listArticle = newMar.getTWebCoreArticle(channelId);
				//声明Map对象
				Map<String,String> map = null;
				if(listArticle!=null&listArticle.size()>0){
					for (TWebCoreArticle core : listArticle) {
						map = new HashMap<String, String>();
						if(core.getTitle().length()>14){
							map.put("title", core.getTitle().substring(0, 14)+"...");
						}else{
							map.put("title", core.getTitle());
						}
						//map.put("time", core.getReleaseSysDate().substring(0,10));
						map.put("articleId", core.getArticleId());
						map.put("channelId", core.getChannelId());
						list.add(map);
					}
				}
				String json = mapper.writeValueAsString(list);
				PrintWriter out  =resp.getWriter();
				out.print(json);
				out.flush();
				out.close();
				return null;
		    }else{
		    	return "error";
		    }
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}
	}
	/**
	 * 查询首页政策法规
	 * @return
	 */
	public String addzcfgNews(){
		HttpServletRequest req = 
			ServletActionContext.getRequest();
		HttpServletResponse resp = 
			ServletActionContext.getResponse();
		resp.setContentType("text/html;utf-8");
		resp.setCharacterEncoding("utf-8");
		try {
			Proerties popUtil = new Proerties();
		    String channelId=null;
		    String pid = getRequest().getParameter("pid");
		    if(pid!=null){
		    	if(pid.equals("11")){//万春镇
					channelId="channelId201311281585791675614208";
				}else if(pid.equals("13")){ //和盛镇
					channelId="channelId201311281585813200946176";
				}else if(pid.equals("15")){ //永宁镇
					channelId="channelId201311281585827743745024";
				}else if(pid.equals("12")){ //寿安镇
					channelId="channelId201311281585801192178688";
				}else if(pid.equals("16")){ //柳城街道
					channelId="channelId201311281585833280242688";
				}else if(pid.equals("22")){ //文教卫体口
					channelId="channelId201311281585861989958656";
				}else if(pid.equals("17")){ //天府街道
					channelId="channelId201311281585838737081344";
				}else if(pid.equals("18")){ //涌泉街道
					channelId="channelId201311281585844111852544";
				}else if(pid.equals("19")){ //公平街道
					channelId="channelId201311281585848455922688";
				}else if(pid.equals("20")){ //永盛镇
					channelId="channelId201311281585852805481472";
				}else if(pid.equals("21")){ //金马镇
					channelId="channelId201311281585856529236992";
				}
		    	List<Map<String,String>> list = new ArrayList<Map<String,String>>();
				List<TWebCoreArticle> listArticle = newMar.getTWebCoreArticle(channelId);
				//声明Map对象
				Map<String,String> map = null;
				if(listArticle!=null&listArticle.size()>0){
					for (TWebCoreArticle core : listArticle) {
						map = new HashMap<String, String>();
						if(core.getTitle().length()>14){
							if(pid.equals("11")){//万春镇
								map.put("title", core.getTitle().substring(0, 20)+"...");
							}else if(pid.equals("13")){ //和盛镇
								map.put("title", core.getTitle().substring(0, 20)+"...");
							}else if(pid.equals("15")){ //永宁镇
								map.put("title", core.getTitle().substring(0, 20)+"...");
							}else if(pid.equals("12")){ //寿安镇
								map.put("title", core.getTitle().substring(0, 20)+"...");
							}else if(pid.equals("16")){ //柳城街道
								map.put("title", core.getTitle().substring(0, 14)+"...");
							}else if(pid.equals("22")){ //文教卫体口
								map.put("title", core.getTitle().substring(0, 14)+"...");
							}else if(pid.equals("17")){ //天府街道
								map.put("title", core.getTitle().substring(0, 14)+"...");
							}else if(pid.equals("18")){ //涌泉街道
								map.put("title", core.getTitle().substring(0, 14)+"...");
							}else if(pid.equals("19")){ //公平街道
								map.put("title", core.getTitle().substring(0, 14)+"...");
							}else if(pid.equals("20")){ //永盛镇
								map.put("title", core.getTitle().substring(0, 20)+"...");
							}else if(pid.equals("21")){ //金马镇
								map.put("title", core.getTitle().substring(0, 20)+"...");
							}
						}else{
							map.put("title", core.getTitle());
						}
						map.put("time", core.getReleaseSysDate().substring(0,10));
						map.put("articleId", core.getArticleId());
						map.put("channelId", core.getChannelId());
						list.add(map);
					}
				}
				String json = mapper.writeValueAsString(list);
				PrintWriter out  =resp.getWriter();
				out.print(json);
				out.flush();
				out.close();
				return null;
		    }else{
		    	return "error";
		    }
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}
	}
	/**
	 * 根据栏目id查询代表风采(ajax)
	 */
	public String getTWebRepQueryAjax(){
		HttpServletResponse resp = 
			ServletActionContext.getResponse();
		resp.setContentType("text/html;utf-8");
		resp.setCharacterEncoding("utf-8");
		try {
		    String channelId=null;
		    String nid=null;
		    String pid = getRequest().getParameter("pid");
		    if(pid!=null){
		    	if(pid.equals("11")){//万春镇
					channelId="channelId201311281585790329832448";
					nid="1104";
				}else if(pid.equals("13")){ //和盛镇
					channelId="channelId201311281585810175673344";
					nid="1304";
				}else if(pid.equals("15")){ //永宁镇
					channelId="channelId201311281585824623821824";
					nid="1504";
				}else if(pid.equals("12")){ //寿安镇
					channelId="channelId201311281585800549270528";
					nid="1204";
				}else if(pid.equals("16")){ //柳城街道
					channelId="channelId201311281585832398947328";
					nid="1604";
				}else if(pid.equals("22")){ //文教卫体口
					channelId="channelId201311281585861740758016";
					nid="2204";
				}else if(pid.equals("17")){ //天府街道
					channelId="channelId201311281585838003897344";
					nid="1704";
				}else if(pid.equals("18")){ //涌泉街道
					channelId="channelId201311281585842996757504";
					nid="1804";
				}else if(pid.equals("19")){ //公平街道
					channelId="channelId201311281585847811867648";
					nid="1905";
				}else if(pid.equals("20")){ //永盛镇
					channelId="channelId201311281585852021736448";
					nid="2004";
				}else if(pid.equals("21")){ //金马镇
					channelId="channelId201311281585856796623872";
					nid="2104";
				}
			Proerties popUtil = new Proerties();
			String url = popUtil.getValue("wjrdht");
				List<Map<String,String>> list = new ArrayList<Map<String,String>>();
				List<TWebCoreMien> reps= repQueryMar.getTWebCoreMienPid(nid);
				//声明Map对象
				Map<String,String> map = null;
				if(reps.size()>0){
					for(TWebCoreMien rep : reps){
						map = new HashMap<String, String>();
						map.put("articleId", rep.getArticleId());
						map.put("channelId", channelId);
						map.put("name", rep.getName());
						if(rep.getTitleImg()!=null&&rep.getTitleImg().length()>0){
						map.put("titleImg",url+"/uploadfile/"+rep.getTitleImg());
						}else{
						map.put("titleImg","");	
						}
						list.add(map);
					}
				}
				String json = mapper.writeValueAsString(list);
				PrintWriter out  =resp.getWriter();
				out.print(json);
				out.flush();
				out.close();
				return null;
		    }else{
		    	return "error";
		    }
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}
	}
	/**
	 * 查询首页图片集锦
	 * @return
	 */
	public String addtpjjNews(){
		HttpServletResponse resp = 
			ServletActionContext.getResponse();
		resp.setContentType("text/html;utf-8");
		resp.setCharacterEncoding("utf-8");
		try {
			Proerties popUtil = new Proerties();
		    String channelId=null;
			String url = popUtil.getValue("wjrdht");
		    String pid = getRequest().getParameter("pid");
		    if(pid!=null){
		    	if(pid.equals("11")){//万春镇
					channelId="channelId201311281585791233901568";
				}else if(pid.equals("13")){ //和盛镇
					channelId="channelId201311281585812086719488";
				}else if(pid.equals("15")){ //永宁镇
					channelId="channelId201311281585825302283264";
				}else if(pid.equals("12")){ //寿安镇
					channelId="channelId201311281585796510499840";
				}else if(pid.equals("16")){ //柳城街道
					channelId="channelId201311281585832735966208";
				}else if(pid.equals("22")){ //文教卫体口
					channelId="channelId201311281585859512108032";
				}else if(pid.equals("17")){ //天府街道
					channelId="channelId201311281585838351238144";
				}else if(pid.equals("18")){ //涌泉街道
					channelId="channelId201311281585843436504064";
				}else if(pid.equals("19")){ //公平街道
					channelId="channelId201311281585848140366848";
				}else if(pid.equals("20")){ //永盛镇
					channelId="channelId201311281585852308620288";
				}else if(pid.equals("21")){ //金马镇
					channelId="channelId201311281585854509745152";
				}
		    	List<Map<String,String>> list = new ArrayList<Map<String,String>>();
				List<TWebCoreArticle> listArticle = newMar.getTWebCoreArticle(channelId);
				//声明Map对象
				Map<String,String> map = null;
				if(listArticle!=null&listArticle.size()>0){
					for (TWebCoreArticle core : listArticle) {
						map = new HashMap<String, String>();
						if(core.getTitle().length()>10){
							map.put("title", core.getTitle().substring(0, 10)+"...");
						}else{
							map.put("title", core.getTitle());
						}
						map.put("allTitle", core.getTitle());
						if(core.getTitleImg()!=null&&core.getTitleImg().length()>0){
							map.put("titleImg",url+"/uploadfile/"+core.getTitleImg());
						}else{
							map.put("titleImg","");	
						}
						map.put("articleId", core.getArticleId());
						map.put("channelId", core.getChannelId());
						list.add(map);
					}
				}
				String json = mapper.writeValueAsString(list);
				PrintWriter out  =resp.getWriter();
				out.print(json);
				out.flush();
				out.close();
				return null;
		    }else{
		    	return "error";
		    }
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}
	}
	/**
	 * 根据栏目id查询友情链接(ajax)
	 */
	public String getTWebLinksQueryAjax(){
		HttpServletResponse resp = 
			ServletActionContext.getResponse();
		resp.setContentType("text/html;utf-8");
		resp.setCharacterEncoding("utf-8");
		try {
		    String channelId=null;
		    String pid = getRequest().getParameter("pid");
		    if(pid!=null){
		    	if(pid.equals("11")){//万春镇
					channelId="channelId201311281585791007310848";
				}else if(pid.equals("13")){ //和盛镇
					channelId="channelId201311281585810360828928";
				}else if(pid.equals("15")){ //永宁镇
					channelId="channelId201311281585825067664384";
				}else if(pid.equals("12")){ //寿安镇
					channelId="channelId201311281585797200593920";
				}else if(pid.equals("16")){ //柳城街道
					channelId="channelId201311281585832591787008";
				}else if(pid.equals("22")){ //文教卫体口
					channelId="channelId201311281585860113236992";
				}else if(pid.equals("17")){ //天府街道
					channelId="channelId201311281585838162658304";
				}else if(pid.equals("18")){ //涌泉街道
					channelId="channelId201311281585843242517504";
				}else if(pid.equals("19")){ //公平街道
					channelId="channelId201311281585847987176448";
				}else if(pid.equals("20")){ //永盛镇
					channelId="channelId201311281585852189017088";
				}else if(pid.equals("21")){ //金马镇
					channelId="channelId201311281585854261527552";
				}
			Proerties popUtil = new Proerties();
			String url = popUtil.getValue("wjrdht");
				List<Map<String,String>> list = new ArrayList<Map<String,String>>();
				List<TWebLinks> Links= linksQueryMar.getTWebLinksQuery(channelId);
				//声明Map对象
				Map<String,String> map = null;
				if(Links.size()>0){
					for(TWebLinks links : Links){
						map = new HashMap<String, String>();
						map.put("linksId", links.getLinksId());
						map.put("channelId", channelId);
						map.put("title", links.getTitle());
						if(links.getYl2()!=null&&links.getYl2().length()>0){
						map.put("titleImg",url+"/uploadfile/"+links.getYl2());
						}else{
						map.put("titleImg","");	
						}
						if(links.getUrl().contains("http://")){
							map.put("url",links.getUrl());	
						}else{
							map.put("url","http://"+links.getUrl());	
						}
						list.add(map);
					}
				}
			
				String json = mapper.writeValueAsString(list);
				PrintWriter out  =resp.getWriter();
				out.print(json);
				out.flush();
				out.close();
				return null;
	
		    }else{
		    	return "error";
		    }
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}
	}
	/**
	 * 根据栏目id查询友情链接
	 */
	public String getTWebLinksQuery(){
		HttpServletResponse resp = 
			ServletActionContext.getResponse();
		resp.setContentType("text/html;utf-8");
		resp.setCharacterEncoding("utf-8");
		try {
			Proerties popUtil = new Proerties();
			String url = popUtil.getValue("wjrdht");
		    String channelId=null;
			String path = getRequest().getContextPath();
		    String pid = getRequest().getParameter("pid");
		    if(pid!=null){
		    	if(pid.equals("11")){//万春镇
					channelId="channelId201311281585791007310848";
					getRequest().setAttribute("topimage",path+"/images/logo_wc.png");
				}else if(pid.equals("13")){ //和盛镇
					channelId="channelId201311281585810360828928";
					getRequest().setAttribute("topimage",path+"/images/logo_hs.png");
				}else if(pid.equals("15")){ //永宁镇
					channelId="channelId201311281585825067664384";
					getRequest().setAttribute("topimage",path+"/images/logo_yn.png");
				}else if(pid.equals("12")){ //寿安镇
					channelId="channelId201311281585797200593920";
					getRequest().setAttribute("topimage",path+"/images/logo_sa.png");
				}else if(pid.equals("16")){ //柳城街道
					channelId="channelId201311281585832591787008";
					getRequest().setAttribute("topimage",path+"/images/logo_lc.png");
				}else if(pid.equals("22")){ //文教卫体口
					channelId="channelId201311281585860113236992";
					getRequest().setAttribute("topimage",path+"/images/logo_wjtwk.png");
				}else if(pid.equals("17")){ //天府街道
					channelId="channelId201311281585838162658304";
					getRequest().setAttribute("topimage",path+"/images/logo_tf.png");
				}else if(pid.equals("18")){ //涌泉街道
					channelId="channelId201311281585843242517504";
					getRequest().setAttribute("topimage",path+"/images/logo_yq.png");
				}else if(pid.equals("19")){ //公平街道
					channelId="channelId201311281585847987176448";
					getRequest().setAttribute("topimage",path+"/images/logo_gp.png");
				}else if(pid.equals("20")){ //永盛镇
					channelId="channelId201311281585852189017088";
					getRequest().setAttribute("topimage",path+"/images/logo_ys.png");
				}else if(pid.equals("21")){ //金马镇
					channelId="channelId201311281585854261527552";
					getRequest().setAttribute("topimage",path+"/images/logo_jm.png");
				}
				List<Map<String,String>> list = new ArrayList<Map<String,String>>();
				List<TWebLinks> Links= linksQueryMar.getTWebLinksQuery(channelId);
				//声明Map对象
				Map<String,String> map = null;
				if(Links.size()>0){
					for(TWebLinks links : Links){
						if(links.getUrl()!=null&&links.getUrl().contains("http://")){
							links.setUrl(links.getUrl());
						}else{
							links.setUrl("http://"+links.getUrl());
						}
						if(links.getYl2()!=null&&links.getYl2().length()>0){
							links.setYl2(url+"/uploadfile/"+links.getYl2());
						}else{
							links.setYl2("");
						}
						list.add(map);
					}
				}
				getRequest().setAttribute("pid",pid);
				getRequest().setAttribute("links", Links);
				return "success";
			}else{
				return "error";
			}
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}
	}
	/**
	 * 分页查看图片集锦页面
	 */
	@SuppressWarnings("unchecked")
	public String getpicarticleQuery(){
		try{
			String path = getRequest().getContextPath();
			String pid = getRequest().getParameter("pid");
			String channelId = getRequest().getParameter("channelId");
			//跳转指定页面
			String zhi="zsuccess";
			if(pid!=null&&!pid.equals("")){
				if(pid.equals("11")){//万春镇
					getRequest().setAttribute("topimage",path+"/images/logo_wc.png");
					//zhi="zsuccess";
				}else if(pid.equals("13")){ //和盛镇
					getRequest().setAttribute("topimage",path+"/images/logo_hs.png");
					//zhi="zsuccess";
				}else if(pid.equals("15")){ //永宁镇
					getRequest().setAttribute("topimage",path+"/images/logo_yn.png");
					//zhi="zsuccess";
				}else if(pid.equals("12")){ //寿安镇
					getRequest().setAttribute("topimage",path+"/images/logo_sa.png");
					//zhi="zsuccess";
				}else if(pid.equals("16")){ //柳城街道
					getRequest().setAttribute("topimage",path+"/images/logo_lc.png");
					//zhi="jdsuccess";
				}else if(pid.equals("22")){ //文教卫体口
					getRequest().setAttribute("topimage",path+"/images/logo_wjtwk.png");
					//zhi="jdsuccess";
				}else if(pid.equals("17")){ //天府街道
					getRequest().setAttribute("topimage",path+"/images/logo_tf.png");
					//zhi="jdsuccess";
				}else if(pid.equals("18")){ //涌泉街道
					getRequest().setAttribute("topimage",path+"/images/logo_yq.png");
					//zhi="jdsuccess";
				}else if(pid.equals("19")){ //公平街道
					getRequest().setAttribute("topimage",path+"/images/logo_gp.png");
					//zhi="jdsuccess";
				}else if(pid.equals("20")){ //永盛镇
					getRequest().setAttribute("topimage",path+"/images/logo_ys.png");
					//zhi="zsuccess";
				}else if(pid.equals("21")){ //金马镇
					getRequest().setAttribute("topimage",path+"/images/logo_jm.png");
					//zhi="zsuccess";
				}
				Proerties popUtil = new Proerties();
				String url = popUtil.getValue("wjrdht");
				//声明List结果集，用于装载查询结果
				List<Map<String, String>> list = null;
				Map<String, String> map = null;
				HttpServletRequest request = ServletActionContext.getRequest();
					//根据栏目ID查询栏目信息
					TWebCoreChannel twebCoreChannel=newMar.getTWebCoreChannelId(channelId);
					this.initExtableGrid(10);// 每页显示条数
					try {
						PageUtil.setPageDispatchInfo(request,pm);
					} catch (Exception e) {
						e.printStackTrace();
						return "error";
					}
					//根据栏目分页查询栏目信息
					pm = articleQueryMar.getTWebCoreArticleChannelId(pm, channelId);
					int totalNum = pm.getRsCount();
					List<TWebCoreArticle> objList = (List<TWebCoreArticle>) pm.getRsList();
					list = new ArrayList<Map<String, String>>();
					//查询数据结果
					if(totalNum != 0){
						for(int i=0;i<objList.size();i++){
							map = new HashMap<String, String>();
							if(i%2==0){
								String hang = "hang";
								map.put("hang", hang);
							}
							if(objList.get(i).getTitleImg()!=null&&!objList.get(i).getTitleImg().equals("")){
								map.put("titleImg",url+"/uploadfile/"+objList.get(i).getTitleImg());  	
							}else{
								map.put("titleImg",""); 
							}
							map.put("articleId", objList.get(i).getArticleId());
							if(objList.get(i).getTitle().length()>36){
								map.put("title", objList.get(i).getTitle().substring(0,36)+"..."); 
							}else{
								map.put("title", objList.get(i).getTitle());  
							}
							map.put("releaseSysDate", objList.get(i).getReleaseSysDate().substring(0,10));
							list.add(map);
						}
					}
					request.setAttribute("channel", twebCoreChannel);
					request.setAttribute(prefix, list);
					request.setAttribute(prefix + "_totalRows",new Integer(totalNum));
					getRequest().setAttribute("pid",pid);
					return zhi;
				}else{
					return "error";
				}
		}catch(Exception e){
			e.printStackTrace();
			return "error";
		}
	}
	/**
	 * 根据栏目Nid查询栏目（ajax）
	 */
	public String selectNidChannel(){
		HttpServletResponse resp = 
			ServletActionContext.getResponse();
		resp.setContentType("text/html;utf-8");
		resp.setCharacterEncoding("utf-8");
		try {
			String pid = getRequest().getParameter("pid");
			String nid=null;
			if(pid!=null&&!pid.equals("")){
				if(pid.equals("11")){//万春镇
					nid="1106";
				}else if(pid.equals("13")){ //和盛镇
					nid="1306";
				}else if(pid.equals("15")){ //永宁镇
					nid="1506";
				}else if(pid.equals("12")){ //寿安镇
					nid="1205";
				}else if(pid.equals("16")){ //柳城街道
					nid="1606";
				}else if(pid.equals("22")){ //文教卫体口
					nid="2205";
				}else if(pid.equals("17")){ //天府街道
					nid="1706";
				}else if(pid.equals("18")){ //涌泉街道
					nid="1806";
				}else if(pid.equals("19")){ //公平街道
					nid="1907";
				}else if(pid.equals("20")){ //永盛镇
					nid="2006";
				}else if(pid.equals("21")){ //金马镇
					nid="2106";
				}
				List<Map<String,String>> list = new ArrayList<Map<String,String>>();
				List<TWebCoreChannel> listchannel= newMar.getTWebCoreChannelNid(nid);
				//声明Map对象
				Map<String,String> map = null;
				for (TWebCoreChannel channel : listchannel) {
					map = new HashMap<String, String>();
					map.put("name", channel.getName().substring( channel.getName().length()-4));
					map.put("channelId", channel.getChannelId());
					list.add(map);
				}
				String json = mapper.writeValueAsString(list);
				PrintWriter out  =resp.getWriter();
				out.print(json);
				out.flush();
				out.close();
				return null;
			}else{
				return "error";
			}
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}
	}
	public String picarticlexxxx()throws HibernateException{
		try{
			Proerties popUtil = new Proerties();
			String url = popUtil.getValue("wjrdht");
			String path = getRequest().getContextPath();
			String pid = getRequest().getParameter("pid");
			//跳转指定页面
			String zhi="zsuccess";
			if(pid!=null&&!pid.equals("")){
				if(pid.equals("11")){//万春镇
					getRequest().setAttribute("topimage",path+"/images/logo_wc.png");
					//zhi="zsuccess";
				}else if(pid.equals("13")){ //和盛镇
					getRequest().setAttribute("topimage",path+"/images/logo_hs.png");
					//zhi="zsuccess";
				}else if(pid.equals("15")){ //永宁镇
					getRequest().setAttribute("topimage",path+"/images/logo_yn.png");
					//zhi="zsuccess";
				}else if(pid.equals("12")){ //寿安镇
					getRequest().setAttribute("topimage",path+"/images/logo_sa.png");
					//zhi="zsuccess";
				}else if(pid.equals("16")){ //柳城街道
					getRequest().setAttribute("topimage",path+"/images/logo_lc.png");
					//zhi="jdsuccess";
				}else if(pid.equals("22")){ //文教卫体口
					getRequest().setAttribute("topimage",path+"/images/logo_wjtwk.png");
					//zhi="jdsuccess";
				}else if(pid.equals("17")){ //天府街道
					getRequest().setAttribute("topimage",path+"/images/logo_tf.png");
					//zhi="jdsuccess";
				}else if(pid.equals("18")){ //涌泉街道
					getRequest().setAttribute("topimage",path+"/images/logo_yq.png");
					//zhi="jdsuccess";
				}else if(pid.equals("19")){ //公平街道
					getRequest().setAttribute("topimage",path+"/images/logo_gp.png");
					//zhi="jdsuccess";
				}else if(pid.equals("20")){ //永盛镇
					getRequest().setAttribute("topimage",path+"/images/logo_ys.png");
					//zhi="zsuccess";
				}else if(pid.equals("21")){ //金马镇
					getRequest().setAttribute("topimage",path+"/images/logo_jm.png");
					//zhi="zsuccess";
				}
				TWebCoreChannel twebCoreChannel=null;
				//声明List结果集，用于装载查询结果
				HttpServletRequest request = ServletActionContext.getRequest();
				String articleId=getRequest().getParameter("articleId");
				if(articleId !=null&!articleId.equals("")){
					//根据新闻Id查询新闻信息
					TWebCoreArticle twebCoreArticle=articleQueryMar.getTWebCoreArticleId(articleId);
					if(twebCoreArticle.getChannelId()!=null&&!twebCoreArticle.getChannelId().equals("")){
						//根据栏目ID查询栏目信息
						twebCoreChannel=newMar.getTWebCoreChannelId(twebCoreArticle.getChannelId());
						request.setAttribute("channel", twebCoreChannel);
					}
					if(twebCoreArticle.getExlink()!=null&&twebCoreArticle.getExlink().length()!=0){
						if(twebCoreArticle.getExlink().contains("http://")){
							String newExlink=twebCoreArticle.getExlink().replace("http://", "");
							twebCoreArticle.setExlink(newExlink);
						}
					}else{
						twebCoreArticle.setExlink("");
					}
					if(twebCoreArticle.getAttachment()!=null&&twebCoreArticle.getAttachment().length()!=0){
						twebCoreArticle.setAttachment(url+"/UploadFiles"+twebCoreArticle.getAttachment());
					}else{
						twebCoreArticle.setAttachment("");
					}
					if(twebCoreArticle.getAttaName()!=null&&twebCoreArticle.getAttaName().length()!=0){
						twebCoreArticle.setAttaName(twebCoreArticle.getAttaName());
					}else{
						twebCoreArticle.setAttaName("");
					}
					if(twebCoreArticle.getViewAddress()!=null&&twebCoreArticle.getViewAddress().length()!=0){
						twebCoreArticle.setViewAddress(url+"/flv"+twebCoreArticle.getViewAddress());
					}else{
						twebCoreArticle.setViewAddress("");
					}
					if(twebCoreArticle.getViewName()!=null&&twebCoreArticle.getViewName().length()!=0){
						twebCoreArticle.setViewName(twebCoreArticle.getViewName());
					}else{
						twebCoreArticle.setViewName("");
					}
					if(twebCoreArticle.getAuthor()!=null&&twebCoreArticle.getAuthor().length()!=0){
						twebCoreArticle.setAuthor(twebCoreArticle.getAuthor());
					}else{
						twebCoreArticle.setAuthor("");
					}
					getRequest().setAttribute("pid",pid);
					request.setAttribute("article", twebCoreArticle);
					return zhi;
				}else{
					return "error";
				}
			}else{
				return "error";
			}
		}catch(Exception e){
			e.printStackTrace();
			return "error";
		}
	}
}
